<template>
  <el-card>
    <el-row>
      <el-breadcrumb separator="/">
        <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
        <el-breadcrumb-item><a href="/">线下就诊订单管理</a></el-breadcrumb-item>
        <el-breadcrumb-item>线下就诊信息列表</el-breadcrumb-item>
      </el-breadcrumb>
    </el-row>
    <el-row>
      <el-input v-model="queryInfo.query"></el-input>
      <el-button type="primary" @click="search()">搜索</el-button>
    </el-row>
    <el-table :data="orderlist" border style="width: 100%" stripe>
      <el-table-column prop="name" label="姓名"> </el-table-column>
      <el-table-column prop="age" label="姓名"> </el-table-column>
      <el-table-column prop="sex" label="姓名"> </el-table-column>
      <el-table-column prop="date" label="下单时间"> </el-table-column>
      <el-table-column prop="phone" label="联系电话"> </el-table-column>
      <el-table-column label="订单状态">
          <template slot-scope="scope">
              <el-tag v-if="scope.row.orderDate == null" type="danger" size="mini">未处理</el-tag>
              <el-tag v-else type="success" size="mini">已处理</el-tag>
          </template>
      </el-table-column>
      <el-table-column label="操作/处理">
          <template>
              <el-button type="danger" size="mini">退款</el-button>
              <el-button type="primary" size="mini">提醒处理</el-button>
          </template>
      </el-table-column>
    </el-table>
     <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="queryInfo.pagenum"
      :page-sizes="[10, 20, 30, 40]"
      :page-size="queryInfo.pagesize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total"
    >
    </el-pagination>
  </el-card>
</template>

<script>
export default {
    data(){
        return{
            orderlist:[],
            queryInfo:{
                pagenum:1,
                pagesize:10,
                query:''
            },
            total:''
        }
    },
    created(){
        this.getOrderList()
    },
    methods:{
        async getOrderList(){
            const { data : res } = await this.$http.get('/api/order/allorders',this.queryInfo)
            if(res.status != 200) return  res.$notify.error('获取列表失败')
            this.orderlist = res.orderList
            this.total = res.total
            this.$notify.success('获取线下就诊列表成功')
            console.log(res)
        },
        handleSizeChange(newSize){
            this.queryInfo.pagesize = newSize
        },
        handleCurrentChange(newPage){
            this.queryInfo.pagenum = newPage
        },
        search(){
            if(queryInfo,query == '') return this.$message.info('搜索内容不可为空')
            this.getOrderList()
        }
    }
};
</script>

<style  scoped>
.el-table {
  margin-top: 30px;
  margin-bottom: 30px;
}
.el-breadcrumb {
  margin-bottom: 20px;
}
.el-input {
  width: 300px;
  margin-right: 5px;
}
</style>